from django.contrib import admin
from .models import Host, HostGroup, Project, Environment, UserGroup


@admin.register(Host)
class HostAdmin(admin.ModelAdmin):
    list_display = ['hostname', 'ip_address', 'port', 'status', 'host_group', 'project', 'environment']
    list_filter = ['status', 'host_group', 'project', 'environment']
    search_fields = ['hostname', 'ip_address']


@admin.register(HostGroup)
class HostGroupAdmin(admin.ModelAdmin):
    list_display = ['name', 'description', 'created_at']
    search_fields = ['name']


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ['name', 'code', 'created_at']
    search_fields = ['name', 'code']


@admin.register(Environment)
class EnvironmentAdmin(admin.ModelAdmin):
    list_display = ['name', 'env_type', 'created_at']
    list_filter = ['env_type']
    search_fields = ['name']


@admin.register(UserGroup)
class UserGroupAdmin(admin.ModelAdmin):
    list_display = ['name', 'created_at']
    search_fields = ['name']
    filter_horizontal = ['users']
